package com.xiaoshuidi.cloud.module.bpm.api.task;

import com.xiaoshuidi.cloud.framework.common.pojo.CommonResult;
import com.xiaoshuidi.cloud.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO;
import com.xiaoshuidi.cloud.module.bpm.api.task.dto.BpmTaskRespDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import javax.validation.Valid;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * 流程实例 Api 接口
 *
 * @author 
 */
@FeignClient(name = "lease-bpm-server")
public interface BpmProcessInstanceApi {

    /**
     * 创建流程实例（提供给内部）
     *
     * @param userId 用户编号
     * @param reqDTO 创建信息
     * @return 实例的编号
     */
    @PostMapping("/rpc-api/bpm/instance/create")
    CommonResult<String> createProcessInstance(@RequestParam("userId") Long userId, @Valid @RequestBody BpmProcessInstanceCreateReqDTO reqDTO);


    /**
     * 通过流程实例id获取流程节点信息
     * @param processInstanceId
     * @return
     */
    @GetMapping("/rpc-api/bpm/task/list-all-by-process-instance-id")
    List<BpmTaskRespDTO> getAllTaskListByProcessInstanceId(@RequestParam("processInstanceId") String processInstanceId);

    /**
     * 通过流程实例获取审批结果
     * @param processInstanceId
     * @return
     */
    @GetMapping("/rpc-api/bpm/instance/result")
    Integer getProcessResult(@RequestParam("processInstanceId") String processInstanceId);

    /**
     * 获取流程实例审批结果
     * @param processInstanceId
     * @return
     */
    @PostMapping("/rpc-api/bpm/instance/get-result-map")
    Map<String, Integer> getProcessResultMap(@RequestBody Set<String> processInstanceId);

    /**
     * 获取流程变量
     * @param processInstanceId
     * @return
     */
    @GetMapping("/rpc-api/bpm/instance/get-result-variables-map")
    CommonResult<Map<String, Object>> getProcessVariablesMap(@RequestParam("processInstanceId") String processInstanceId);
}
